#ifndef _PROTOCOL_H_IMPLEMENTATION_H_
#define _PROTOCOL_H_IMPLEMENTATION_H_

#include "../virtual/Virtual.h"

class ProtocolImplementation : public Device 
{
	protected :
		//input the protocol implementation uses 
		//to perform data operations. Needs to be 
		//volatile since I could set these in interrupts
		//that aren't necessarily apart of the main program
		//and I can't guarantee for every compiler that I will
		//have a good memory mapping that will do the mapping
		//for these variables correctly.
		volatile unsigned char in;
		//the output the protocol implementations uses to perform
		//receive data operations. Needs to be volatile for the same
		//reason above.
		volatile unsigned char out;
		//error calculation this is optional and depends on the 
		//protocol used.
		volatile bool error;
		//parity calculation this is optional and depends on the 
		//protocol used.
		volatile bool parity;

	public:
		//flag that determines if the receive is finished.
		//the flags should be in reality the only things volatile
		//but that will wait until a later version.
		volatile bool receiveFinished;
		//flag that determines if the transmit is finished.
		//this is the same as the previous flag
		volatile bool transmitFinished;
		//reconfigures the implementation if it needs to be
		//reconfigured.
		virtual void config()=0;
		//initializes the implementation if needed.
		virtual void init()=0;
		//transmits data using the implementation
		//if transmission is finished and there is more data
		//to be sent it will start the next transmission
		virtual void transmitData()=0;
		//receive data using the implementation
		//if receive is finished it will start the next receive
		virtual void receiveData()=0;
		//schedules a transmit interrupt to occur.
		//or schedules to start polling the transmit
		//transmit operation
		virtual void scheduleTransmitInterrupt()=0;
		//schedules a receive interrupt to occur.
		virtual void scheduleReceiveInterrupt()=0;
		//runs the protocol implementation and sets the
		//next data to transmit and receives the data that
		//hase been inputted
		virtual void run()=0;
		//sets the value of in to i
		void setIn(unsigned char i){in = i;}
		//gets the value of out
		unsigned char getOut(){	return out;}	
		//gets the parity of operation. Up to user to use
		volatile bool getParity(){return parity;}
		//gets the error of operation. Up to user to use
		volatile bool getError(){return error;}
		//gets the receive finished flag.
		 bool getReceiveFinished(){return receiveFinished;}
		//gets the transmit finished flag.
		bool getTransmitFinished(){return transmitFinished;}

		//resets the transmit flag
		void resetTransmit(){transmitFinished=false;}
		//resets the receive flag
		void resetReceive(){receiveFinished=false;}


};


#endif

